<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let hero = {
            name: '吕布',
            level: 18,
            skill: function (age) {
                console.log(age + '天崩地裂');
            }
        }

        //1. 获取对象属性的两种方式
        // 对象名.属性名
        //对象名[字符串] 字符串是属性名

        console.log(hero.name);
        console.log(hero['level']);

        //2.变量是window 的属性
        var age = 2;

        //3.window 一般省略
        console.log(age);
        console.log(window.age);
        //4.对象方法的调用
        hero.skil();
        hero.skill(12);
        function eat() {
            console.log('吃火锅');
        }
        eat();
        window.eat();

        //5.对象可以动态的添加属性（方法）
        hero.address = '艾泽拉斯';
        hero.paly = function () {
            console.log('王者荣耀');
        }
        console.log(hero);
        hero.paly();

        //6. 属性的修改 （变量的重新赋值）
        hero.name = "貂蝉";
        console.log(hero);

        //7. 属性的删除  delete 对象名.属性名
        delete hero.name;
        console.log(hero);
    </script>
</body>

</html>